package com.lwl.office.dcconverter.element;

import com.lwl.office.webeditor.ParserContext;
import lombok.Data;

/**
 * 表格单元格
 */
@Data
public class DCTableCell extends AbsDCElement{
    private int flag;
    private int rowspan;
    private int colspan;
    public DCParagraph addParagraph() {
        DCParagraph dcp=new DCParagraph();
        addChild(dcp);
        return dcp;
    }

    /**
     * valign="top" rowspan="1" colspan="2" style="word-break: break-all;">
     * @return
     */
    @Override
    public String toHtml() {
        StringBuilder stb = new StringBuilder();
        stb.append("<td ");
        if(rowspan>1 || colspan>1){
            stb.append(" rowspan=\"").append(rowspan).append("\"");
            stb.append(" colspan=\"").append(colspan).append("\"");
        }
        if(getStyle()!=null){
            stb.append(getStyle().toHtmlStyle());
        }
        stb.append(">");
        for (AbsDCElement paragraph : getChildren()) {
            stb.append(paragraph.toHtml());
        }
        stb.append("</td>");
        return stb.toString();
    }

    @Override
    public void parseWord(ParserContext context) {

    }
}
